import React, { useEffect, useState } from 'react'
import style from './style.module.scss'
import { UserService } from '../../transfer/service/UserService'
import { Link } from 'react-router-dom'

interface IAvatarProps {
    width: string
    height: string
    userId?: any
    img?: any
}

export default function AvatarView(props: IAvatarProps) {
    const [head, setHead] = useState<any>('')

    // 不同参数获取的头像不同、
    // 传入图片路径
    useEffect(() => {
        if (props.img) setHead(props.img)
    }, [props.img])

    return (
        <div
            className={style.container}
            onClick={() => {
                console.log(test)
            }}
            style={{
                ['--avatar-width' as any]: props.width,
                ['--avatar-height' as any]: props.height
            }}>
            <img src={head} />
        </div>
    )
}
